/**
 * @file    startup_GT9881.c
 * @author  Giantec-Semi ATE
 * @brief   CMSIS Cortex-M4 Device Startup File for GT9881
 * @version 0.1
 * 
 * @copyright Copyright (c) 2021 Giantec-Semi
 */

/**
 * @addtogroup CMSIS_Device
 * @{
 */

/**
 * @addtogroup GT9881
 * @{
 */

/**
 * @addtogroup GT9881_Startup_Private_Includes
 * @{
 */
#include "gt98xx.h"
/** @} GT9881_Startup_Private_Includes */

/**
 * @addtogroup GT9881_Startup_References
 * @{
 */
extern __NO_RETURN void Reset_Handler(void);
extern __NO_RETURN void HardFault_Handler(void);
extern __NO_RETURN void Default_Handler(void);
/** @} GT9881_Startup_References */

/**
 * @addtogroup GT9881_Startup_Exception_Interrupt_Handler
 * @{
 */
void NMI_Handler            (void) __attribute__ ((weak, alias("Default_Handler")));
void HardFault_Handler      (void) __attribute__ ((weak));
void MemManage_Handler      (void) __attribute__ ((weak, alias("Default_Handler")));
void BusFault_Handler       (void) __attribute__ ((weak, alias("Default_Handler")));
void UsageFault_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
void SVC_Handler            (void) __attribute__ ((weak, alias("Default_Handler")));
void DebugMon_Handler       (void) __attribute__ ((weak, alias("Default_Handler")));
void PendSV_Handler         (void) __attribute__ ((weak, alias("Default_Handler")));
void SysTick_Handler        (void) __attribute__ ((weak, alias("Default_Handler")));

void IIC1_IRQHandler        (void) __attribute__ ((weak, alias("Default_Handler")));
void IIC2_EXTI2_IRQHandler  (void) __attribute__ ((weak, alias("Default_Handler")));
void SPI1_IRQHandler        (void) __attribute__ ((weak, alias("Default_Handler")));
void SPI2_IRQHandler        (void) __attribute__ ((weak, alias("Default_Handler")));
void EXTI1_IRQHandler       (void) __attribute__ ((weak, alias("Default_Handler")));
void GPIO_IRQHandler        (void) __attribute__ ((weak, alias("Default_Handler")));
void AFC_IRQHandler         (void) __attribute__ ((weak, alias("Default_Handler")));
void ADC_IRQHandler         (void) __attribute__ ((weak, alias("Default_Handler")));
void UVLO_IRQHandler        (void) __attribute__ ((weak, alias("Default_Handler")));
void IWDT_IRQHandler        (void) __attribute__ ((weak, alias("Default_Handler")));
void TIMER0_IRQHandler      (void) __attribute__ ((weak, alias("Default_Handler")));
void TIMER123_IRQHandler    (void) __attribute__ ((weak, alias("Default_Handler")));
void RINGBUFFER_IRQHandler  (void) __attribute__ ((weak, alias("Default_Handler")));
void UART_IRQHandler        (void) __attribute__ ((weak, alias("Default_Handler")));
void DMA_CH0_IRQHandler     (void) __attribute__ ((weak, alias("Default_Handler")));
void DMA_CH1_IRQHandler     (void) __attribute__ ((weak, alias("Default_Handler")));
void CORDIC_IRQHandler      (void) __attribute__ ((weak, alias("Default_Handler")));
void PWMOC_IRQHandler       (void) __attribute__ ((weak, alias("Default_Handler")));
void PWMPAS_IRQHandler      (void) __attribute__ ((weak, alias("Default_Handler")));
void SYSMODECTRL_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
void IOVDDLVD_IRQHandler    (void) __attribute__ ((weak, alias("Default_Handler")));
void VM2_IRQHandler         (void) __attribute__ ((weak, alias("Default_Handler")));
void VM1_IRQHandler         (void) __attribute__ ((weak, alias("Default_Handler")));
void TSD_IRQHandler         (void) __attribute__ ((weak, alias("Default_Handler")));
/** @} GT9881_Startup_Exception_Interrupt_Handler */

/**
 * @addtogroup GT9881_Startup_Vector_Table
 * @{
 */
const VECTOR_TABLE_TYPE __VECTOR_TABLE[40] __VECTOR_TABLE_ATTRIBUTE =
{
    (VECTOR_TABLE_TYPE)(&__INITIAL_SP),
    Reset_Handler,                          /*!< Reset Handler */
    NMI_Handler,                            /*!< -14 NMI Handler */
    HardFault_Handler,                      /*!< -13 Hard Fault Handler */
    MemManage_Handler,                      /*!< -12 MPU Fault Handler */
    BusFault_Handler,                       /*!< -11 Bus Fault Handler */
    UsageFault_Handler,                     /*!< -10 Usage Fault Handler */
    0,                                      /*!< Reserved */
    0,                                      /*!< Reserved */
    0,                                      /*!< Reserved */
    0,                                      /*!< Reserved */
    SVC_Handler,                            /*!< -5 SVCall Handler */
    DebugMon_Handler,                       /*!< -4 Debug Monitor Handler */
    0,                                      /*!< Reserved */
    PendSV_Handler,                         /*!< -2 PendSV Handler */
    SysTick_Handler,                        /*!< -1 SysTick Handler */
    /* Interrupts */
    IIC1_IRQHandler,
    IIC2_EXTI2_IRQHandler,
    SPI1_IRQHandler,
    SPI2_IRQHandler,
    EXTI1_IRQHandler,
    GPIO_IRQHandler,
    AFC_IRQHandler,
    ADC_IRQHandler,
    UVLO_IRQHandler,
    IWDT_IRQHandler,
    TIMER0_IRQHandler,
    TIMER123_IRQHandler,
    RINGBUFFER_IRQHandler,
    UART_IRQHandler,
    DMA_CH0_IRQHandler,
    DMA_CH1_IRQHandler,
    
    CORDIC_IRQHandler,
    PWMOC_IRQHandler,
    PWMPAS_IRQHandler,
    SYSMODECTRL_IRQHandler,
    IOVDDLVD_IRQHandler,
    VM2_IRQHandler,
    VM1_IRQHandler,
    TSD_IRQHandler
};

/** @} GT9881_Startup_Vector_Table */

/**
 * @addtogroup GT9881_Startup_Private_Functions
 * @{
 */

/**
 * @fn __NO_RETURN void Reset_Handler(void)
 * @brief Reset entrance
 * 
 * @return None
 */
__NO_RETURN void Reset_Handler(void) {
  SystemInit();
  __PROGRAM_START();
}

/**
 * @fn __NO_RETURN void HardFault_Handler(void)
 * @brief Hard fault exception handler
 * 
 * @return None
 */
__NO_RETURN void HardFault_Handler(void) {
  while (1) {}
}

/**
 * @fn __NO_RETURN void Default_Handler(void)
 * @brief Default exception/interrupt handler
 * 
 * @return None
 */
__NO_RETURN void Default_Handler(void) {
  while (1) {}
}

/** @} GT9881_Startup_Private_Functions */

/** @} GT9881 */
/** @} CMSIS_Device */
